package cn.anecansaitin.firecrafting.common.event;

import cn.anecansaitin.firecrafting.ModConstant;
import cn.anecansaitin.firecrafting.common.world.FireCraftingSavedData;
import net.minecraft.server.level.ServerLevel;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

//每个服务器tick触发计时器
@Mod.EventBusSubscriber(modid = ModConstant.MOD_ID)
public class ServerTickEvent {
    @SubscribeEvent
    public static void serverTick(TickEvent.WorldTickEvent event) {
        //判断服务端
        if (event.side.isServer() && event.phase == TickEvent.Phase.END) {
            //获取data
            FireCraftingSavedData data = FireCraftingSavedData.getInstance((ServerLevel) event.world);
            //触发计时器
            data.tick();
        }
    }
}
